package tmp_GetTypeFromClass;
import zclTool.*;

import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.*;

public class GetProC_gvn_t {
	public static void main(String []args) throws Exception{
		DelimitedReader dr = new DelimitedReader(args[0]);
		OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
				args[1]), "utf-8");
		String []line ;
		ArrayList<String[]>lines = new ArrayList<String[]>();
		HashMap<String,Integer>typeSum=new HashMap<String,Integer>();
		while((line= dr.read())!=null){
			String []temp = new String[line.length];
			System.arraycopy(line, 0, temp, 0, line.length);
			lines.add(temp);
			String type = line[2];
			int cnt = Integer.parseInt(line[0]);
			Integer already = typeSum.get(type);
			if(already == null){
				typeSum.put(type, cnt);
			}else{
				int newval = already+cnt;
				typeSum.remove(type);
				typeSum.put(type, newval);
			}
		}
		dr.close();
		for(String[]a: lines){
			String type = a[2];
			int sum = typeSum.get(type);
			int cnt = Integer.parseInt(a[0]);
			double p = cnt*1.0/sum;
			System.out.println(p+"\t"+a[1]+"\t"+a[2]);
			osw.write(p+"\t"+a[1]+"\t"+a[2]+"\n");
		}
		osw.close();
	}
}
